package com.production.CoursePlatform.service;

import com.production.CoursePlatform.entity.Reply;
import com.production.CoursePlatform.mapper.ReplyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReplyService {

    @Autowired
    private ReplyMapper replyMapper;

    // 创建新的回复记录
    public void createReply(Reply reply) {
        replyMapper.insertReply(reply);
    }


    // 根据cmt_id查找回复记录
    public List<Reply> findReplyByCmtId(int cmtID) {
        return replyMapper.selectByCmtId(cmtID);
    }

    // 根据r_id查找回复记录
    public Reply findReplyByRId(int rID) {
        return replyMapper.selectByRId(rID);
    }

    // 根据r_id删除回复记录
    public int deleteReply(int rID) {
        return replyMapper.deleteByRId(rID);
    }

    // 更新回复记录
    public boolean updateReply(Reply reply) {
        return replyMapper.updateReply(reply) > 0;
    }
}

